#include <iostream>
#include <cstdio>
#define int long long
using namespace std;

const int N = 20;
bool flag[N];
int n,a[N],ans,x[2];

void dfs(int step)
{
    if (step > n)
    {
        x[0] = x[1] = 0;
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            if (x[flag[i]] == a[i]) sum += a[i];
            x[flag[i]] = a[i];
        }
        ans = max(ans,sum);
        return;
    }
    flag[step] = false;
    dfs(step + 1);
    flag[step] = true;
    dfs(step + 1);
}

signed main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin >> t;
    while (t--)
    {
        cin >> n;
        for (int i = 1; i <= n; i++) cin >> a[i];
        ans = -1e9;
        dfs(1);
        cout << ans << endl;
    }
    return 0;
}
